package com.snail.interceptor;


import cn.dev33.satoken.stp.StpUtil;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.stereotype.Component;

/**
 * @author 蔡徐坤
 * @date 2025/8/13 19:35
 * @description: Feign拦截器，用于在Feign请求中添加Sa-Token
 */
@Component
public class SaTokenFeignInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        String tokenName = StpUtil.getTokenName();
        String tokenValue = StpUtil.getTokenValue();
        if (tokenValue != null) {
            template.header(tokenName, tokenValue);
            template.header("X-Gateway-Token", "5201314...");
        }
    }
}
